class Solution {
public:
    double findMaxAverage(vector<int>& nums, int k) {
if (nums.empty() || k <= 0 || k > nums.size()) {
            return 0.00;
        }

        double wsum = 0.00;
        for (int i = 0; i < k; ++i) {
            wsum += nums[i];
        }

        double max_average = wsum / k;
        for (int i = k; i < nums.size(); ++i) {
            wsum += nums[i] - nums[i - k];
            double cur_average = wsum / k;
            if (cur_average > max_average) {
                max_average = cur_average;
            }
        }

        return max_average;
    }
};


